package file01;

import java.io.File;
import java.io.FileFilter;

public class Test {
    public static void main(String[] args) {
        //获取./src/main/java/file下所有名字以D开头的子项
        File dir = new File("./src/main/java/file01");
        if (dir.isDirectory()) {
            FileFilter filter = new FileFilter() {
                @Override
                public boolean accept(File file) {
                    //900字节以下的
//                    long len = file.length();
//                    return len <= 900;
                    //名字含"D"的3
                    String name = file.getName();
                    return name.contains("D");
                }
            };
            File[] subs = dir.listFiles(filter);
            for (File sub : subs) {
                System.out.println(sub.getName());
            }
        }
    }
}
